package CoreClass;

public class CheckName
{
	protected DBCommon dbc = new DBCommon();
	protected String FirstConn;
	private String stringConn;
	private String stringTable;
	private String tempID2;
	private String tempID3;
	private String tempName;

	public CheckName(String ID2, String ID3, String Name)
	{
		this.FirstConn = this.dbc.strConnectstring;
		this.tempName = Name;
		this.tempID2 = ID2;
		this.tempID3 = ID3;
		this.First();
	}

	public final void First()
	{
		SqlCommand mySqlCommand = this.dbc.GetCommandBySql("select x1 server,x2 Data,x3 uid,x4 pwd,x5 biao from d_a where ID=" + this.tempID3);
		mySqlCommand.Connection.Open();
		SqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
		try
		{
			while (mySqlDataReader.Read())
			{
				this.stringConn = "server=" + mySqlDataReader.GetValue(0).toString() + ";User ID=" + mySqlDataReader.GetValue(2).toString() + ";Password=" + mySqlDataReader.GetValue(3).toString() + ";database=" + mySqlDataReader.GetValue(1).toString() + ";Connection Reset=FALSE";
				this.stringTable = mySqlDataReader.GetValue(4).toString();
			}
		}
		finally
		{
			mySqlDataReader.Close();
		}
	}

	public final boolean ValidateName()
	{
		this.First();
		SqlCommand mySqlCommand = this.dbc.GetCommandBySql("select name,id2 from " + this.stringTable.toString() + " where name='" + this.tempName + "' and  ID2=" + this.tempID2.toString());
		mySqlCommand.Connection.Open();
		SqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
		try
		{
			if (mySqlDataReader.Read())
			{
				return false;
			}
		}
		finally
		{
			mySqlDataReader.Close();
		}
		return true;
	}

	public final String getRecordConn()
	{
		return this.stringConn;
	}

	public final String getTableName()
	{
		return this.stringTable;
	}
}